/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __PQ_UISystem_H__
#define __PQ_UISystem_H__

#include "ClientPrerequisites.h"

#include "CEGUI.h"

#include "UIScreen.h"

namespace PQClient
{
	/*This class is used to manage all kind of scenenary ui screen.
	@note We set this class as input listener for we can easily interact with ui.
	*/
	class UISystem :
		public OIS::MouseListener,public OIS::KeyListener
	{
	public:
		static std::string GroupName_ImageSet;
		static std::string GroupName_Font;
		static std::string GroupName_Scheme;
		static std::string GroupName_Layout;
		static std::string GroupName_LookFeel;
	protected:
		UISystem();
	public:
		~UISystem();
		static UISystem& getSingleton()
		{
			static UISystem inst;
			return inst;

		}

		void update(float deltaT);

		void init();

		uint getWindowWidth();
		uint getWindowHeight();

		/*Set current ui screen
		*/
		void setCurrentScreen(UIScreen::Type type);

	protected:
		void initScreens();
		void configCEGUI();
		void updateIMEWindow();
		const CEGUI::Vector2 getCaretPos(const CEGUI::MultiLineEditbox* box);
		const CEGUI::Vector2 getCaretPos(const CEGUI::Editbox* box);

	protected:
		Ogre::RenderWindow* _window;
		//CEGUI::OgreRenderer& _renderer;
		UIScreen* _screens[UIScreen::UIScreen_Count];
		UIScreen* _activeScreen;
	protected:
		bool keyPressed( const OIS::KeyEvent &e );
		bool keyReleased( const OIS::KeyEvent &e );

		bool mouseMoved( const OIS::MouseEvent &e );
		bool mousePressed( const OIS::MouseEvent &e, OIS::MouseButtonID id );
		bool mouseReleased( const OIS::MouseEvent &e, OIS::MouseButtonID id );

	};

}
#endif
